<?php

namespace App\Http\Controllers\Business;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
use Crypt;

class RsetCodeController extends Controller
{
    //reset
    public function reset()
    {
    	return view('business/user/reset');
    }


    //renew
    public function renew(Request $request)
    {
    	$data = $request -> except('_token','repassword');
    	$this -> validate($request,[
    		'repassword' => 'required|same:password'
    		],[
    		'repassword.required' => '确认密码不能为空',
    		'repassword.same' => '两次密码不一样'
    		]);
        
        //处理数据
        $data['password'] = Crypt::encrypt($data['password']);

    	$res = DB::table('businesses') -> where('id', session('master')-> id) -> update($data);

    	if($res)
    	{
    		return redirect('business/index/index');
    	}else
    	{
    		return back() -> with(['info' => '修改密码失败']);
    	}
    }

    

}


